<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Module      :  GHC.Windows</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 2009</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Windows functionality used by several modules.</span><span>
</span><span id="line-16"></span><span class="hs-comment">--</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- ToDo: this just duplicates part of System.Win32.Types, which isn't</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- available yet.  We should move some Win32 functionality down here,</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- maybe as part of the grand reorganisation of the base package...</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Windows</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Types</span></span><span>
</span><span id="line-25"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#BOOL"><span class="hs-identifier">BOOL</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPBOOL"><span class="hs-identifier">LPBOOL</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#BYTE"><span class="hs-identifier">BYTE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier">DWORD</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#DDWORD"><span class="hs-identifier">DDWORD</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#UINT"><span class="hs-identifier">UINT</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#ULONG"><span class="hs-identifier">ULONG</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier">ErrCode</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#HANDLE"><span class="hs-identifier">HANDLE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPWSTR"><span class="hs-identifier">LPWSTR</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPTSTR"><span class="hs-identifier">LPTSTR</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPCTSTR"><span class="hs-identifier">LPCTSTR</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPVOID"><span class="hs-identifier">LPVOID</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPDWORD"><span class="hs-identifier">LPDWORD</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPSTR"><span class="hs-identifier">LPSTR</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPCSTR"><span class="hs-identifier">LPCSTR</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#LPCWSTR"><span class="hs-identifier">LPCWSTR</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#WORD"><span class="hs-identifier">WORD</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#UCHAR"><span class="hs-identifier">UCHAR</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-44"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#NTSTATUS"><span class="hs-identifier">NTSTATUS</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Constants</span></span><span>
</span><span id="line-47"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#iNFINITE"><span class="hs-identifier">iNFINITE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-48"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#iNVALID_HANDLE_VALUE"><span class="hs-identifier">iNVALID_HANDLE_VALUE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span>        </span><span class="annot"><span class="hs-comment">-- * System errors</span></span><span>
</span><span id="line-51"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#throwGetLastError"><span class="hs-identifier">throwGetLastError</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-52"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failWith"><span class="hs-identifier">failWith</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-53"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#getLastError"><span class="hs-identifier">getLastError</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-54"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#getErrorMessage"><span class="hs-identifier">getErrorMessage</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-55"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#errCodeToIOError"><span class="hs-identifier">errCodeToIOError</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Guards for system calls that might fail</span></span><span>
</span><span id="line-58"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failIf"><span class="hs-identifier">failIf</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-59"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failIf_"><span class="hs-identifier">failIf_</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-60"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failIfNull"><span class="hs-identifier">failIfNull</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier">failIfZero</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-62"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failIfFalse_"><span class="hs-identifier">failIfFalse_</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-63"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failUnlessSuccess"><span class="hs-identifier">failUnlessSuccess</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-64"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#failUnlessSuccessOr"><span class="hs-identifier">failUnlessSuccessOr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Mapping system errors to errno</span></span><span>
</span><span id="line-67"></span><span>        </span><span class="annot"><span class="hs-comment">-- $errno</span></span><span>
</span><span id="line-68"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#c_maperrno"><span class="hs-identifier">c_maperrno</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-69"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#c_maperrno_func"><span class="hs-identifier">c_maperrno_func</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Misc</span></span><span>
</span><span id="line-72"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#ddwordToDwords"><span class="hs-identifier">ddwordToDwords</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-73"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#dwordsToDdword"><span class="hs-identifier">dwordsToDdword</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-74"></span><span>        </span><span class="annot"><a href="GHC.Windows.html#nullHANDLE"><span class="hs-identifier">nullHANDLE</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-75"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Bits.html"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Bits.html#shiftL"><span class="hs-identifier">shiftL</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Bits.html#shiftR"><span class="hs-identifier">shiftR</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Bits.html#.%7C."><span class="hs-operator">(.|.)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Bits.html#.%26."><span class="hs-operator">(.&amp;.)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Char.html"><span class="hs-identifier">Data.Char</span></a></span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.OldList.html"><span class="hs-identifier">Data.OldList</span></a></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Maybe.html"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Word.html"><span class="hs-identifier">Data.Word</span></a></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Int.html"><span class="hs-identifier">Data.Int</span></a></span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.Error.html"><span class="hs-identifier">Foreign.C.Error</span></a></span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.String.html"><span class="hs-identifier">Foreign.C.String</span></a></span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.Types.html"><span class="hs-identifier">Foreign.C.Types</span></a></span><span>
</span><span id="line-86"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Ptr.html"><span class="hs-identifier">Foreign.Ptr</span></a></span><span>
</span><span id="line-87"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-88"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Enum.html"><span class="hs-identifier">GHC.Enum</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Enum.html#maxBound"><span class="hs-identifier">maxBound</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.html"><span class="hs-identifier">GHC.IO</span></a></span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Real.html"><span class="hs-identifier">GHC.Real</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier">fromIntegral</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-92"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.IO.Error.html"><span class="hs-identifier">System.IO.Error</span></a></span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Numeric.html"><span class="hs-identifier">Numeric</span></a></span><span class="hs-cpp">

#if MIN_VERSION_base(4,7,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Bits.html"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Bits.html#finiteBitSize"><span class="hs-identifier">finiteBitSize</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Bits</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Bits</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">bitSize</span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span class="hs-identifier">finiteBitSize</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Bits</span><span> </span><span class="hs-identifier">a</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">Int</span><span>
</span><span id="line-102"></span><span class="hs-identifier">finiteBitSize</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">bitSize</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-107"></span><span class="hs-keyword">type</span><span> </span><span id="BOOL"><span class="annot"><a href="GHC.Windows.html#BOOL"><span class="hs-identifier hs-var">BOOL</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-108"></span><span class="hs-keyword">type</span><span> </span><span id="LPBOOL"><span class="annot"><a href="GHC.Windows.html#LPBOOL"><span class="hs-identifier hs-var">LPBOOL</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Windows.html#BOOL"><span class="hs-identifier hs-type">BOOL</span></a></span><span>
</span><span id="line-109"></span><span class="hs-keyword">type</span><span> </span><span id="BYTE"><span class="annot"><a href="GHC.Windows.html#BYTE"><span class="hs-identifier hs-var">BYTE</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-110"></span><span class="hs-keyword">type</span><span> </span><span id="DWORD"><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-var">DWORD</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span>
</span><span id="line-111"></span><span class="hs-keyword">type</span><span> </span><span id="UINT"><span class="annot"><a href="GHC.Windows.html#UINT"><span class="hs-identifier hs-var">UINT</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span>
</span><span id="line-112"></span><span class="hs-keyword">type</span><span> </span><span id="ULONG"><span class="annot"><a href="GHC.Windows.html#ULONG"><span class="hs-identifier hs-var">ULONG</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span>
</span><span id="line-113"></span><span class="hs-keyword">type</span><span> </span><span id="ErrCode"><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-var">ErrCode</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>
</span><span id="line-114"></span><span class="hs-keyword">type</span><span> </span><span id="HANDLE"><span class="annot"><a href="GHC.Windows.html#HANDLE"><span class="hs-identifier hs-var">HANDLE</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-115"></span><span class="hs-keyword">type</span><span> </span><span id="LPWSTR"><span class="annot"><a href="GHC.Windows.html#LPWSTR"><span class="hs-identifier hs-var">LPWSTR</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CWchar"><span class="hs-identifier hs-type">CWchar</span></a></span><span>
</span><span id="line-116"></span><span class="hs-keyword">type</span><span> </span><span id="LPCTSTR"><span class="annot"><a href="GHC.Windows.html#LPCTSTR"><span class="hs-identifier hs-var">LPCTSTR</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPTSTR"><span class="hs-identifier hs-type">LPTSTR</span></a></span><span>
</span><span id="line-117"></span><span class="hs-keyword">type</span><span> </span><span id="LPVOID"><span class="annot"><a href="GHC.Windows.html#LPVOID"><span class="hs-identifier hs-var">LPVOID</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span class="hs-keyword">type</span><span> </span><span id="LPDWORD"><span class="annot"><a href="GHC.Windows.html#LPDWORD"><span class="hs-identifier hs-var">LPDWORD</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>
</span><span id="line-119"></span><span class="hs-keyword">type</span><span> </span><span id="LPSTR"><span class="annot"><a href="GHC.Windows.html#LPSTR"><span class="hs-identifier hs-var">LPSTR</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CChar"><span class="hs-identifier hs-type">CChar</span></a></span><span>
</span><span id="line-120"></span><span class="hs-keyword">type</span><span> </span><span id="LPCSTR"><span class="annot"><a href="GHC.Windows.html#LPCSTR"><span class="hs-identifier hs-var">LPCSTR</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPSTR"><span class="hs-identifier hs-type">LPSTR</span></a></span><span>
</span><span id="line-121"></span><span class="hs-keyword">type</span><span> </span><span id="LPCWSTR"><span class="annot"><a href="GHC.Windows.html#LPCWSTR"><span class="hs-identifier hs-var">LPCWSTR</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPWSTR"><span class="hs-identifier hs-type">LPWSTR</span></a></span><span>
</span><span id="line-122"></span><span class="hs-keyword">type</span><span> </span><span id="WORD"><span class="annot"><a href="GHC.Windows.html#WORD"><span class="hs-identifier hs-var">WORD</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span>
</span><span id="line-123"></span><span class="hs-keyword">type</span><span> </span><span id="UCHAR"><span class="annot"><a href="GHC.Windows.html#UCHAR"><span class="hs-identifier hs-var">UCHAR</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-124"></span><span class="hs-keyword">type</span><span> </span><span id="NTSTATUS"><span class="annot"><a href="GHC.Windows.html#NTSTATUS"><span class="hs-identifier hs-var">NTSTATUS</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Int.html#Int32"><span class="hs-identifier hs-type">Int32</span></a></span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span class="annot"><a href="GHC.Windows.html#nullHANDLE"><span class="hs-identifier hs-type">nullHANDLE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#HANDLE"><span class="hs-identifier hs-type">HANDLE</span></a></span><span>
</span><span id="line-127"></span><span id="nullHANDLE"><span class="annot"><span class="annottext">nullHANDLE :: HANDLE
</span><a href="GHC.Windows.html#nullHANDLE"><span class="hs-identifier hs-var hs-var">nullHANDLE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HANDLE
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span class="hs-comment">-- Not really a basic type, but used in many places</span><span>
</span><span id="line-130"></span><span class="hs-keyword">type</span><span> </span><span id="DDWORD"><span class="annot"><a href="GHC.Windows.html#DDWORD"><span class="hs-identifier hs-var">DDWORD</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-comment">-- | Be careful with this.  LPTSTR can mean either WCHAR* or CHAR*, depending</span><span>
</span><span id="line-133"></span><span class="hs-comment">-- on whether the UNICODE macro is defined in the corresponding C code.</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- Consider using LPWSTR instead.</span><span>
</span><span id="line-135"></span><span class="hs-keyword">type</span><span> </span><span id="LPTSTR"><span class="annot"><a href="GHC.Windows.html#LPTSTR"><span class="hs-identifier hs-var">LPTSTR</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Windows.html#LPWSTR"><span class="hs-identifier hs-type">LPWSTR</span></a></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span class="annot"><a href="GHC.Windows.html#iNFINITE"><span class="hs-identifier hs-type">iNFINITE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span>
</span><span id="line-138"></span><span id="iNFINITE"><span class="annot"><span class="annottext">iNFINITE :: DWORD
</span><a href="GHC.Windows.html#iNFINITE"><span class="hs-identifier hs-var hs-var">iNFINITE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0xFFFFFFFF</span></span><span> </span><span class="hs-comment">-- urgh</span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="annot"><a href="GHC.Windows.html#iNVALID_HANDLE_VALUE"><span class="hs-identifier hs-type">iNVALID_HANDLE_VALUE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#HANDLE"><span class="hs-identifier hs-type">HANDLE</span></a></span><span>
</span><span id="line-141"></span><span id="iNVALID_HANDLE_VALUE"><span class="annot"><span class="annottext">iNVALID_HANDLE_VALUE :: HANDLE
</span><a href="GHC.Windows.html#iNVALID_HANDLE_VALUE"><span class="hs-identifier hs-var hs-var">iNVALID_HANDLE_VALUE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WordPtr -&gt; HANDLE
forall a. WordPtr -&gt; Ptr a
</span><a href="Foreign.Ptr.html#wordPtrToPtr"><span class="hs-identifier hs-var">wordPtrToPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">WordPtr
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-- | Get the last system error, and throw it as an 'IOError' exception.</span><span>
</span><span id="line-144"></span><span id="local-6989586621679543540"><span class="annot"><a href="GHC.Windows.html#throwGetLastError"><span class="hs-identifier hs-type">throwGetLastError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543540"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-145"></span><span id="throwGetLastError"><span class="annot"><span class="annottext">throwGetLastError :: forall a. String -&gt; IO a
</span><a href="GHC.Windows.html#throwGetLastError"><span class="hs-identifier hs-var hs-var">throwGetLastError</span></a></span></span><span> </span><span id="local-6989586621679543401"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543401"><span class="hs-identifier hs-var">where_from</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-146"></span><span>    </span><span class="annot"><span class="annottext">IO DWORD
</span><a href="GHC.Windows.html#getLastError"><span class="hs-identifier hs-var">getLastError</span></a></span><span> </span><span class="annot"><span class="annottext">IO DWORD -&gt; (DWORD -&gt; IO a) -&gt; IO a
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; DWORD -&gt; IO a
forall a. String -&gt; DWORD -&gt; IO a
</span><a href="GHC.Windows.html#failWith"><span class="hs-identifier hs-var">failWith</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543401"><span class="hs-identifier hs-var">where_from</span></a></span><span>
</span><span id="line-147"></span><span>
</span><span id="line-148"></span><span class="hs-comment">-- | Convert a Windows error code to an exception, then throw it.</span><span>
</span><span id="line-149"></span><span id="local-6989586621679543535"><span class="annot"><a href="GHC.Windows.html#failWith"><span class="hs-identifier hs-type">failWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543535"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-150"></span><span id="failWith"><span class="annot"><span class="annottext">failWith :: forall a. String -&gt; DWORD -&gt; IO a
</span><a href="GHC.Windows.html#failWith"><span class="hs-identifier hs-var hs-var">failWith</span></a></span></span><span> </span><span id="local-6989586621679543397"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543397"><span class="hs-identifier hs-var">fn_name</span></a></span></span><span> </span><span id="local-6989586621679543396"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543396"><span class="hs-identifier hs-var">err_code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-151"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; DWORD -&gt; IO IOError
</span><a href="GHC.Windows.html#errCodeToIOError"><span class="hs-identifier hs-var">errCodeToIOError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543397"><span class="hs-identifier hs-var">fn_name</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543396"><span class="hs-identifier hs-var">err_code</span></a></span><span> </span><span class="annot"><span class="annottext">IO IOError -&gt; (IOError -&gt; IO a) -&gt; IO a
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">IOError -&gt; IO a
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span>
</span><span id="line-152"></span><span>
</span><span id="line-153"></span><span class="hs-comment">-- | Convert a Windows error code to an exception.</span><span>
</span><span id="line-154"></span><span class="annot"><a href="GHC.Windows.html#errCodeToIOError"><span class="hs-identifier hs-type">errCodeToIOError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.IO.Exception.html#IOError"><span class="hs-identifier hs-type">IOError</span></a></span><span>
</span><span id="line-155"></span><span id="errCodeToIOError"><span class="annot"><span class="annottext">errCodeToIOError :: String -&gt; DWORD -&gt; IO IOError
</span><a href="GHC.Windows.html#errCodeToIOError"><span class="hs-identifier hs-var hs-var">errCodeToIOError</span></a></span></span><span> </span><span id="local-6989586621679543394"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543394"><span class="hs-identifier hs-var">fn_name</span></a></span></span><span> </span><span id="local-6989586621679543393"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543393"><span class="hs-identifier hs-var">err_code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-156"></span><span>    </span><span id="local-6989586621679543392"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543392"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; IO String
</span><a href="GHC.Windows.html#getErrorMessage"><span class="hs-identifier hs-var">getErrorMessage</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543393"><span class="hs-identifier hs-var">err_code</span></a></span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span>    </span><span class="hs-comment">-- turn GetLastError() into errno, which errnoToIOError knows</span><span>
</span><span id="line-159"></span><span>    </span><span class="hs-comment">-- how to convert to an IOException we can throw.</span><span>
</span><span id="line-160"></span><span>    </span><span class="hs-comment">-- XXX we should really do this directly.</span><span>
</span><span id="line-161"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679543391"><span class="annot"><span class="annottext">errno :: Errno
</span><a href="#local-6989586621679543391"><span class="hs-identifier hs-var hs-var">errno</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; Errno
</span><a href="GHC.Windows.html#c_maperrno_func"><span class="hs-identifier hs-var">c_maperrno_func</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543393"><span class="hs-identifier hs-var">err_code</span></a></span><span>
</span><span id="line-162"></span><span>
</span><span id="line-163"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679543390"><span class="annot"><span class="annottext">msg' :: String
</span><a href="#local-6989586621679543390"><span class="hs-identifier hs-var hs-var">msg'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Bool) -&gt; String -&gt; String
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="Data.OldList.html#dropWhileEnd"><span class="hs-identifier hs-var">dropWhileEnd</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="GHC.Unicode.html#isSpace"><span class="hs-identifier hs-var">isSpace</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543392"><span class="hs-identifier hs-var">msg</span></a></span><span> </span><span class="hs-comment">-- drop trailing \n</span><span>
</span><span id="line-164"></span><span>        </span><span id="local-6989586621679543387"><span class="annot"><span class="annottext">ioerror :: IOError
</span><a href="#local-6989586621679543387"><span class="hs-identifier hs-var hs-var">ioerror</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Errno -&gt; Maybe Handle -&gt; Maybe String -&gt; IOError
</span><a href="Foreign.C.Error.html#errnoToIOError"><span class="hs-identifier hs-var">errnoToIOError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543394"><span class="hs-identifier hs-var">fn_name</span></a></span><span> </span><span class="annot"><span class="annottext">Errno
</span><a href="#local-6989586621679543391"><span class="hs-identifier hs-var">errno</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Handle
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe String
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-165"></span><span>                    </span><span class="annot"><span class="annottext">IOError -&gt; String -&gt; IOError
</span><a href="System.IO.Error.html#ioeSetErrorString"><span class="hs-operator hs-var">`ioeSetErrorString`</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543390"><span class="hs-identifier hs-var">msg'</span></a></span><span>
</span><span id="line-166"></span><span>    </span><span class="annot"><span class="annottext">IOError -&gt; IO IOError
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">IOError
</span><a href="#local-6989586621679543387"><span class="hs-identifier hs-var">ioerror</span></a></span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="hs-comment">-- | Get a string describing a Windows error code.  This uses the</span><span>
</span><span id="line-169"></span><span class="hs-comment">-- @FormatMessage@ system call.</span><span>
</span><span id="line-170"></span><span class="annot"><a href="GHC.Windows.html#getErrorMessage"><span class="hs-identifier hs-type">getErrorMessage</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-171"></span><span id="getErrorMessage"><span class="annot"><span class="annottext">getErrorMessage :: DWORD -&gt; IO String
</span><a href="GHC.Windows.html#getErrorMessage"><span class="hs-identifier hs-var hs-var">getErrorMessage</span></a></span></span><span> </span><span id="local-6989586621679543384"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543384"><span class="hs-identifier hs-var">err_code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-172"></span><span>    </span><span class="annot"><span class="annottext">IO String -&gt; IO String
forall a. IO a -&gt; IO a
</span><a href="GHC.IO.html#mask_"><span class="hs-identifier hs-var">mask_</span></a></span><span> </span><span class="annot"><span class="annottext">(IO String -&gt; IO String) -&gt; IO String -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-173"></span><span>        </span><span id="local-6989586621679543382"><span class="annot"><span class="annottext">LPWSTR
</span><a href="#local-6989586621679543382"><span class="hs-identifier hs-var">c_msg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; IO LPWSTR
</span><a href="GHC.Windows.html#c_getErrorMessage"><span class="hs-identifier hs-var">c_getErrorMessage</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543384"><span class="hs-identifier hs-var">err_code</span></a></span><span>
</span><span id="line-174"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">LPWSTR
</span><a href="#local-6989586621679543382"><span class="hs-identifier hs-var">c_msg</span></a></span><span> </span><span class="annot"><span class="annottext">LPWSTR -&gt; LPWSTR -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">LPWSTR
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span>
</span><span id="line-175"></span><span>          </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; IO String) -&gt; String -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Error 0x&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; String -&gt; String
forall a. (Integral a, Show a) =&gt; a -&gt; String -&gt; String
</span><a href="Numeric.html#showHex"><span class="hs-identifier hs-var">Numeric.showHex</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543384"><span class="hs-identifier hs-var">err_code</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span>
</span><span id="line-176"></span><span>          </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679543379"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543379"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LPWSTR -&gt; IO String
</span><a href="Foreign.C.String.html#peekCWString"><span class="hs-identifier hs-var">peekCWString</span></a></span><span> </span><span class="annot"><span class="annottext">LPWSTR
</span><a href="#local-6989586621679543382"><span class="hs-identifier hs-var">c_msg</span></a></span><span>
</span><span id="line-177"></span><span>                  </span><span class="hs-comment">-- We ignore failure of freeing c_msg, given we're already failing</span><span>
</span><span id="line-178"></span><span>                  </span><span class="annot"><span class="annottext">LPWSTR
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LPWSTR -&gt; IO LPWSTR
forall a. Ptr a -&gt; IO (Ptr a)
</span><a href="GHC.Windows.html#localFree"><span class="hs-identifier hs-var">localFree</span></a></span><span> </span><span class="annot"><span class="annottext">LPWSTR
</span><a href="#local-6989586621679543382"><span class="hs-identifier hs-var">c_msg</span></a></span><span>
</span><span id="line-179"></span><span>                  </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543379"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-180"></span><span>
</span><span id="line-181"></span><span id="local-6989586621679543516"><span class="annot"><a href="GHC.Windows.html#failIf"><span class="hs-identifier hs-type">failIf</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679543516"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543516"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543516"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-182"></span><span id="failIf"><span class="annot"><span class="annottext">failIf :: forall a. (a -&gt; Bool) -&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIf"><span class="hs-identifier hs-var hs-var">failIf</span></a></span></span><span> </span><span id="local-6989586621679543374"><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679543374"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679543373"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543373"><span class="hs-identifier hs-var">wh</span></a></span></span><span> </span><span id="local-6989586621679543372"><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679543372"><span class="hs-identifier hs-var">act</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-183"></span><span>    </span><span id="local-6989586621679543371"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679543371"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679543372"><span class="hs-identifier hs-var">act</span></a></span><span>
</span><span id="line-184"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679543374"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679543371"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO a
forall a. String -&gt; IO a
</span><a href="GHC.Windows.html#throwGetLastError"><span class="hs-identifier hs-var">throwGetLastError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543373"><span class="hs-identifier hs-var">wh</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">a -&gt; IO a
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679543371"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span id="local-6989586621679543514"><span class="annot"><a href="GHC.Windows.html#failIf_"><span class="hs-identifier hs-type">failIf_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679543514"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543514"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-187"></span><span id="failIf_"><span class="annot"><span class="annottext">failIf_ :: forall a. (a -&gt; Bool) -&gt; String -&gt; IO a -&gt; IO ()
</span><a href="GHC.Windows.html#failIf_"><span class="hs-identifier hs-var hs-var">failIf_</span></a></span></span><span> </span><span id="local-6989586621679543368"><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679543368"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679543367"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543367"><span class="hs-identifier hs-var">wh</span></a></span></span><span> </span><span id="local-6989586621679543366"><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679543366"><span class="hs-identifier hs-var">act</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-188"></span><span>    </span><span id="local-6989586621679543365"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679543365"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO a
</span><a href="#local-6989586621679543366"><span class="hs-identifier hs-var">act</span></a></span><span>
</span><span id="line-189"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">a -&gt; Bool
</span><a href="#local-6989586621679543368"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679543365"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO ()
forall a. String -&gt; IO a
</span><a href="GHC.Windows.html#throwGetLastError"><span class="hs-identifier hs-var">throwGetLastError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543367"><span class="hs-identifier hs-var">wh</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-190"></span><span>
</span><span id="line-191"></span><span id="local-6989586621679543512"><span class="annot"><a href="GHC.Windows.html#failIfNull"><span class="hs-identifier hs-type">failIfNull</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543512"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543512"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-192"></span><span id="failIfNull"><span class="annot"><span class="annottext">failIfNull :: forall a. String -&gt; IO (Ptr a) -&gt; IO (Ptr a)
</span><a href="GHC.Windows.html#failIfNull"><span class="hs-identifier hs-var hs-var">failIfNull</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Ptr a -&gt; Bool) -&gt; String -&gt; IO (Ptr a) -&gt; IO (Ptr a)
forall a. (a -&gt; Bool) -&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIf"><span class="hs-identifier hs-var">failIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr a -&gt; Ptr a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span id="local-6989586621679543510"><span class="annot"><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-type">failIfZero</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-type">Eq</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543510"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Num.html#Num"><span class="hs-identifier hs-type">Num</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543510"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543510"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543510"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-195"></span><span id="failIfZero"><span class="annot"><span class="annottext">failIfZero :: forall a. (Eq a, Num a) =&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIfZero"><span class="hs-identifier hs-var hs-var">failIfZero</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; Bool) -&gt; String -&gt; IO a -&gt; IO a
forall a. (a -&gt; Bool) -&gt; String -&gt; IO a -&gt; IO a
</span><a href="GHC.Windows.html#failIf"><span class="hs-identifier hs-var">failIf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; a -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>
</span><span id="line-196"></span><span>
</span><span id="line-197"></span><span class="annot"><a href="GHC.Windows.html#failIfFalse_"><span class="hs-identifier hs-type">failIfFalse_</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-198"></span><span id="failIfFalse_"><span class="annot"><span class="annottext">failIfFalse_ :: String -&gt; IO Bool -&gt; IO ()
</span><a href="GHC.Windows.html#failIfFalse_"><span class="hs-identifier hs-var hs-var">failIfFalse_</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; String -&gt; IO Bool -&gt; IO ()
forall a. (a -&gt; Bool) -&gt; String -&gt; IO a -&gt; IO ()
</span><a href="GHC.Windows.html#failIf_"><span class="hs-identifier hs-var">failIf_</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#not"><span class="hs-identifier hs-var">not</span></a></span><span>
</span><span id="line-199"></span><span>
</span><span id="line-200"></span><span class="annot"><a href="GHC.Windows.html#failUnlessSuccess"><span class="hs-identifier hs-type">failUnlessSuccess</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span id="failUnlessSuccess"><span class="annot"><span class="annottext">failUnlessSuccess :: String -&gt; IO DWORD -&gt; IO ()
</span><a href="GHC.Windows.html#failUnlessSuccess"><span class="hs-identifier hs-var hs-var">failUnlessSuccess</span></a></span></span><span> </span><span id="local-6989586621679543358"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543358"><span class="hs-identifier hs-var">fn_name</span></a></span></span><span> </span><span id="local-6989586621679543357"><span class="annot"><span class="annottext">IO DWORD
</span><a href="#local-6989586621679543357"><span class="hs-identifier hs-var">act</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-202"></span><span>    </span><span id="local-6989586621679543356"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543356"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO DWORD
</span><a href="#local-6989586621679543357"><span class="hs-identifier hs-var">act</span></a></span><span>
</span><span id="line-203"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543356"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; DWORD -&gt; IO ()
forall a. String -&gt; DWORD -&gt; IO a
</span><a href="GHC.Windows.html#failWith"><span class="hs-identifier hs-var">failWith</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543358"><span class="hs-identifier hs-var">fn_name</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543356"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-204"></span><span>
</span><span id="line-205"></span><span class="annot"><a href="GHC.Windows.html#failUnlessSuccessOr"><span class="hs-identifier hs-type">failUnlessSuccessOr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-206"></span><span id="failUnlessSuccessOr"><span class="annot"><span class="annottext">failUnlessSuccessOr :: DWORD -&gt; String -&gt; IO DWORD -&gt; IO Bool
</span><a href="GHC.Windows.html#failUnlessSuccessOr"><span class="hs-identifier hs-var hs-var">failUnlessSuccessOr</span></a></span></span><span> </span><span id="local-6989586621679543355"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543355"><span class="hs-identifier hs-var">val</span></a></span></span><span> </span><span id="local-6989586621679543354"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543354"><span class="hs-identifier hs-var">fn_name</span></a></span></span><span> </span><span id="local-6989586621679543353"><span class="annot"><span class="annottext">IO DWORD
</span><a href="#local-6989586621679543353"><span class="hs-identifier hs-var">act</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-207"></span><span>    </span><span id="local-6989586621679543352"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543352"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO DWORD
</span><a href="#local-6989586621679543353"><span class="hs-identifier hs-var">act</span></a></span><span>
</span><span id="line-208"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543352"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>
</span><span id="line-209"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543352"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DWORD -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543355"><span class="hs-identifier hs-var">val</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO Bool
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-210"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; DWORD -&gt; IO Bool
forall a. String -&gt; DWORD -&gt; IO a
</span><a href="GHC.Windows.html#failWith"><span class="hs-identifier hs-var">failWith</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679543354"><span class="hs-identifier hs-var">fn_name</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543352"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-211"></span><span>
</span><span id="line-212"></span><span class="hs-comment">-- $errno</span><span>
</span><span id="line-213"></span><span class="hs-comment">--</span><span>
</span><span id="line-214"></span><span class="hs-comment">-- On Windows, @errno@ is defined by msvcrt.dll for compatibility with other</span><span>
</span><span id="line-215"></span><span class="hs-comment">-- systems, and is distinct from the system error as returned</span><span>
</span><span id="line-216"></span><span class="hs-comment">-- by @GetLastError@.</span><span>
</span><span id="line-217"></span><span>
</span><span id="line-218"></span><span class="hs-comment">-- | Map the last system error to an errno value, and assign it to @errno@.</span><span>
</span><span id="line-219"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;maperrno&quot;</span></span><span>             </span><span class="hs-comment">-- in Win32Utils.c</span><span>
</span><span id="line-220"></span><span>   </span><span id="c_maperrno"><span class="annot"><a href="GHC.Windows.html#c_maperrno"><span class="hs-identifier hs-var">c_maperrno</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span>
</span><span id="line-222"></span><span class="hs-comment">-- | Pure function variant of 'c_maperrno' that does not call @GetLastError@</span><span>
</span><span id="line-223"></span><span class="hs-comment">-- or modify @errno@.</span><span>
</span><span id="line-224"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;maperrno_func&quot;</span></span><span>        </span><span class="hs-comment">-- in Win32Utils.c</span><span>
</span><span id="line-225"></span><span>   </span><span id="c_maperrno_func"><span class="annot"><a href="GHC.Windows.html#c_maperrno_func"><span class="hs-identifier hs-var">c_maperrno_func</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Error.html#Errno"><span class="hs-identifier hs-type">Errno</span></a></span><span>
</span><span id="line-226"></span><span>
</span><span id="line-227"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;base_getErrorMessage&quot;</span></span><span> </span><span class="hs-comment">-- in Win32Utils.c</span><span>
</span><span id="line-228"></span><span>    </span><span id="c_getErrorMessage"><span class="annot"><a href="GHC.Windows.html#c_getErrorMessage"><span class="hs-identifier hs-var">c_getErrorMessage</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Windows.html#LPWSTR"><span class="hs-identifier hs-type">LPWSTR</span></a></span><span>
</span><span id="line-229"></span><span>
</span><span id="line-230"></span><span id="local-6989586621679543517"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h LocalFree&quot;</span><span>
</span><span id="line-231"></span><span>    </span><span id="localFree"><span class="annot"><a href="GHC.Windows.html#localFree"><span class="hs-identifier hs-var">localFree</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543517"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679543517"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span class="hs-comment">-- | Get the last system error produced in the current thread.</span><span>
</span><span id="line-234"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetLastError&quot;</span><span>
</span><span id="line-235"></span><span>    </span><span id="getLastError"><span class="annot"><a href="GHC.Windows.html#getLastError"><span class="hs-identifier hs-var">getLastError</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="GHC.Windows.html#ErrCode"><span class="hs-identifier hs-type">ErrCode</span></a></span><span>
</span><span id="line-236"></span><span>
</span><span id="line-237"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-238"></span><span class="hs-comment">-- Misc helpers</span><span>
</span><span id="line-239"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span class="annot"><a href="GHC.Windows.html#ddwordToDwords"><span class="hs-identifier hs-type">ddwordToDwords</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#DDWORD"><span class="hs-identifier hs-type">DDWORD</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-242"></span><span id="ddwordToDwords"><span class="annot"><span class="annottext">ddwordToDwords :: DDWORD -&gt; (DWORD, DWORD)
</span><a href="GHC.Windows.html#ddwordToDwords"><span class="hs-identifier hs-var hs-var">ddwordToDwords</span></a></span></span><span> </span><span id="local-6989586621679543351"><span class="annot"><span class="annottext">DDWORD
</span><a href="#local-6989586621679543351"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-243"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DDWORD -&gt; DWORD
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DDWORD
</span><a href="#local-6989586621679543351"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">DDWORD -&gt; Int -&gt; DDWORD
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; Int
forall b. FiniteBits b =&gt; b -&gt; Int
</span><a href="Data.Bits.html#finiteBitSize"><span class="hs-identifier hs-var">finiteBitSize</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DWORD
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-244"></span><span>        </span><span class="hs-special">,</span><span class="annot"><span class="annottext">DDWORD -&gt; DWORD
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DDWORD
</span><a href="#local-6989586621679543351"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">DDWORD -&gt; DDWORD -&gt; DDWORD
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; DDWORD
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DWORD
forall a. Bounded a =&gt; a
</span><a href="GHC.Enum.html#maxBound"><span class="hs-identifier hs-var">maxBound</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-245"></span><span>
</span><span id="line-246"></span><span class="annot"><a href="GHC.Windows.html#dwordsToDdword"><span class="hs-identifier hs-type">dwordsToDdword</span></a></span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Windows.html#DWORD"><span class="hs-identifier hs-type">DWORD</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Windows.html#DDWORD"><span class="hs-identifier hs-type">DDWORD</span></a></span><span>
</span><span id="line-247"></span><span id="dwordsToDdword"><span class="annot"><span class="annottext">dwordsToDdword :: (DWORD, DWORD) -&gt; DDWORD
</span><a href="GHC.Windows.html#dwordsToDdword"><span class="hs-identifier hs-var hs-var">dwordsToDdword</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679543349"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543349"><span class="hs-identifier hs-var">hi</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679543348"><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543348"><span class="hs-identifier hs-var">low</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DWORD -&gt; DDWORD
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543348"><span class="hs-identifier hs-var">low</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">DDWORD -&gt; DDWORD -&gt; DDWORD
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="Data.Bits.html#.%7C."><span class="hs-operator hs-var">.|.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DWORD -&gt; DDWORD
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543349"><span class="hs-identifier hs-var">hi</span></a></span><span> </span><span class="annot"><span class="annottext">DDWORD -&gt; Int -&gt; DDWORD
forall a. Bits a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Bits.html#shiftL"><span class="hs-operator hs-var">`shiftL`</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD -&gt; Int
forall b. FiniteBits b =&gt; b -&gt; Int
</span><a href="Data.Bits.html#finiteBitSize"><span class="hs-identifier hs-var">finiteBitSize</span></a></span><span> </span><span class="annot"><span class="annottext">DWORD
</span><a href="#local-6989586621679543349"><span class="hs-identifier hs-var">hi</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-248"></span></pre></body></html>